using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Data;
using BLL.BusinessLayer;
using BLL.BusinessLayer.DataLayer;

/// <summary>
/// Summary description for WSClsTest_Question
/// </summary>
/// 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class WSClsTest_Question : System.Web.Services.WebService

    {
        ClsTest_QuestionSql _dataObject = null;
        
        public WSClsTest_Question () {

            //Uncomment the following line if using designed components 
            //InitializeComponent(); 
            _dataObject = new ClsTest_QuestionSql();
        }
        [WebMethod]
        public string HelloWorld() {
            return "Hello World";
        }

        [WebMethod(Description = "Apps_GetAllToDataTable", EnableSession = false)]
        public DataTable ClsTest_Question_GetAllToDataTable()
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            try
            {
                BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql fa = new BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql();
            
                ds = fa.GetAllToDataSet();

                dt = ds.Tables[0];
                return dt ;
            }
            catch (System.Exception ex) { }
            return dt;
        }

        [WebMethod(Description = "ClsTest_Question_SelectByFieldToDataTable", EnableSession = false)]
        public DataTable SelectByFieldToDataTable(string fieldName, object value)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            try
            {
                BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql fa = new BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql();
                ds = fa.SelectByFieldToDataSet(fieldName, value);

                dt = ds.Tables[0];
                return dt ;
            }
            catch (System.Exception ex) { }
            return dt;
        }

        [WebMethod(Description = "ClsTest_Question_SelectSqlToDataTable", EnableSession = false)]
        public DataTable SelectSqlToDataTable(string strSql)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            try
            {
                BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql fa = new BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql();
                ds = fa.SelectSqlToDataTable(strSql);

                dt = ds.Tables[0];
                return dt ;
            }
            catch (System.Exception ex) { }
            return dt;
        }

        [WebMethod(Description = "ClsTest_Question_SelectTableByWhereSql (Only where)", EnableSession = false)]
        public DataTable SelectTableByWhereSql(string strwhere)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            try
            {
                BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql fa = new BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql();
                ds = fa.SelectTableByWhereSql(strwhere);

                dt = ds.Tables[0];
                return dt ;
            }
            catch (System.Exception ex) { }
            return dt;
        }

        [WebMethod(Description = "ClsTest_Question_RunSQL (Full SQL String)", EnableSession = false)]
        public bool RunSQL(string strSQL)
        {
            try
            {
                BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql fa = new BLL.BusinessLayer.DataLayer.ClsTest_QuestionSql();
                bool result = fa.RunSQL(strSQL);

                return result;
            }
            catch (System.Exception ex) { 
                return false;
            }
            
        }

        #region Public Methods

        /// <summary>
        /// insert new row in the table
        /// </summary>
		/// <param name="businessObject">business object</param>
		/// <returns>true of successfully insert</returns>
        /// 
        
		/// <summary>
        /// Insert new ClsTest_Question
        /// </summary>
        /// <param name="businessObject">ClsTest_Question object</param>
        /// <returns>true for successfully saved</returns>
        [WebMethod(Description = "Insert new ClsTest_Question\ntrue for successfully saved", EnableSession = false)]
        public bool ClsTest_Question_Insert(ClsTest_Question businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }
            return _dataObject.Insert(businessObject);
        }

        /// <summary>
        /// Update existing ClsTest_Question
        /// </summary>
        /// <param name="businessObject">ClsTest_Question object</param>
        /// <returns>true for successfully saved</returns>
        [WebMethod(Description = "Update existing ClsTest_Question\ntrue for successfully saved", EnableSession = false)]
        public bool ClsTest_Question_Update(ClsTest_Question businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Update(businessObject);
        }

        /// <summary>
        /// get ClsTest_Question by primary key.
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>ClsTest_Question</returns>
        [WebMethod(Description = "get ClsTest_Question by primary key. return ClsTest_Question", EnableSession = false)]
        public ClsTest_Question ClsTest_Question_GetByPrimaryKey(ClsTest_QuestionKeys keys)
        {
            return _dataObject.SelectByPrimaryKey(keys); 
        }
        /// <summary>
        /// get list of all ClsTest_Questions
        /// </summary>
        /// <returns>list</returns>
        [WebMethod(Description = "get list of all ClsTest_Questions. return list of ClsTest_Question", EnableSession = false)]
        public List<ClsTest_Question> ClsTest_Question_GetAll()
        {
            return _dataObject.SelectAll(); 
        }
        /// <summary>
        /// get list of ClsTest_Question by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        [WebMethod(Description = "get list of ClsTest_Question by field. return list of ClsTest_Question", EnableSession = false)]
        public List<ClsTest_Question> ClsTest_Question_GetAllBy(ClsTest_Question.ClsTest_QuestionFields fieldName, object value)
        {
            return _dataObject.SelectByField(fieldName.ToString(), value);  
        }

        /// <summary>
        /// delete by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>true for succesfully deleted</returns>
        [WebMethod(Description = "delete ClsTest_Question true for succesfully deleted", EnableSession = false)]
        public bool ClsTest_Question_DeleteByKeys(ClsTest_QuestionKeys keys)
        {
            return _dataObject.Delete(keys); 
        }

        /// <summary>
        /// delete ClsTest_Question by field.
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>true for successfully deleted</returns>
        [WebMethod(Description = "delete ClsTest_Question by field. true for successfully deleted", EnableSession = false)]
        public bool ClsTest_Question_DeleteByField(ClsTest_Question.ClsTest_QuestionFields fieldName, object value)
        {
            return _dataObject.DeleteByField(fieldName.ToString(), value); 
        }
     #endregion
    }